package com.ym.medical.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ym.core.utils.tkmybatis.BaseSVImpl;
import com.ym.medical.dao.UserCollectionDao;
import com.ym.medical.domain.entity.UserCollectionEntity;
import com.ym.medical.domain.param.AddressListParam;
import com.ym.medical.domain.param.UserCollectionQueryParam;
import com.ym.medical.domain.param.UserCollectionUpdateParam;
import com.ym.medical.domain.vo.PCMyDoctorVo;
import com.ym.medical.domain.vo.UserCollectionListPcVO;
import com.ym.medical.enums.CollectLableTypeEnum;
import com.ym.medical.service.IUserCollectionSV;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
                                                                        
/**
* 收藏有问诊记录，药品，器械，文章Service业务层处理
*
* @author ym
* @date 2020-09-04
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class UserCollectionSVImpl extends BaseSVImpl<UserCollectionEntity,UserCollectionDao> implements IUserCollectionSV {

	/**
	 * 查询是否关注
	 *
	 * @param busId 业务相关ID
	 * @param currId 用户ID
	 * @return
	 */
	@Override
	public long selectAttention(Long busId, Long currId, CollectLableTypeEnum type) {
		return mapper.selectAttention(busId, currId,type.getKey());
	}

	/**
	 * 当前用户收藏的话题获取时所需数据
	 * @param listModel
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@Override
	public PageInfo<PCMyDoctorVo> pcCollectionTopic(AddressListParam listModel, int pageNo, int pageSize) {
		PageHelper.startPage(pageNo,pageSize);
		List<PCMyDoctorVo> userCollectionVo =
				mapper.pcCollectionTopic(listModel);
		return new PageInfo<>(userCollectionVo);
	}
	/**
	 * 文章收藏列表
	 * @param listModel
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	@Override
	public PageInfo<PCMyDoctorVo> pcCollectArticle(AddressListParam listModel, int pageNo, int pageSize) {
		PageHelper.startPage(pageNo,pageSize);
		List<PCMyDoctorVo> userCollectionVo = mapper.pcCollectArticle(listModel);
		return new PageInfo<>(userCollectionVo);
	}

}
